package cz.cuni.mff.ufal.volk.command;

public class PingIntervalCommand extends Command {
  
  /**
   * Creates new {@code PingIntervalCommand} with the given interval.
   * 
   * @param interval new ping interval in seconds; the interval must be at least 1 and at most 255
   */
  public PingIntervalCommand(int interval) {
    if (interval < 1 || interval > 0xff)
      throw new IllegalArgumentException("The interval parameter is not within the allowed range");
    this.interval = interval;
  }
  
  private final int interval;

  @Override
  public byte commandType() {
    return 03;
  }

  @Override
  public byte[] getBytes() {
    byte b = 0;
    b |= interval & 0xff;
    return new byte[] { b };
  }

}
